package com.avalon.core.select;

import com.avalon.core.condition.Condition;
import com.avalon.core.field.Field;
import com.avalon.core.field.FieldList;
import com.avalon.core.select.builder.SelectBuilder;
import com.avalon.core.service.AbstractService;

public class ConditionField {
    private String originField;
    private Field field;//最后一个字段
    private Condition condition;//条件
    private FieldList tableList;//之前字段对应的表名
    private AbstractService service;

    public String getOriginField() {
        return originField;
    }

    protected void setOriginField(String originField) {
        this.originField = originField;
    }

    public Field getField() {
        return field;
    }

    protected void setField(Field field) {
        this.field = field;
    }

    public Condition getCondition() {
        return condition;
    }

    protected void setCondition(Condition condition) {
        this.condition = condition;
    }

    public FieldList getTableList() {
        return tableList;
    }

    protected void setTableList(FieldList tableList) {
        this.tableList = tableList;
    }

    public ConditionField(String originField, Condition condition, AbstractService service) {
        this.originField = originField;
        this.condition = condition;
        this.service = service;
    }

    public StringBuilder getConditionSql(SelectBuilder selectBuilder) {
        StringBuilder sql = new StringBuilder();
        if (condition != null) {
            sql.append(condition.getSql(selectBuilder));
        }
        return sql;
    }
}
